<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      template="/pages/templates/internal.xhtml">
    <ui:define name="head">
        <title>Administrar Grupos</title>
    </ui:define>
    <ui:define name="body">
        <f:event type="preRenderView" listener="#{mainAdministratorController.init()}"/>
        <h:form id="formGrupos">
            <p:menubar>
                <f:facet name="options">
                    <p:commandButton value="Nuevo Grupo" action="#{mainAdministratorController.goToviewNewGroup()}" />
                </f:facet>
            </p:menubar>
            <p:dataTable id="tableGrupos" var="group" value="#{mainAdministratorController.groups}">
                <p:column headerText="Grupo">
                    <h:outputText value="#{group.nombre}"/>
                </p:column>
                <p:column headerText="Acciones">
                    <p:commandLink value="Editar" 
                                   action="#{editGroupController.saveGrupo(group)}" 
                                   ajax="false" />
                    <p:spacer width="10"/>
                    <p:commandLink value="Eliminar" 
                                   action="#{editGroupController.delete(group)}" 
                                   ajax="false" />
                </p:column>
            </p:dataTable>
        </h:form>
    </ui:define>
</ui:composition>